﻿define(['text', 'text!/public/modules/layui-pagination/layui-pagination-template.html'],
    function (text, template) {

        Vue.component('layui-pagination', {
            template: template
        });

        var module = function (pagination, onPageChangeCallback) {
            var setting = {
                cont: 'pagination',
                pages: pagination.TotalPages,
                curr: pagination.Page,
                jump: function () {
                    // 使第一页加载的时候不执行回调函数
                    if (this.curr == setting.curr) return;
                    setting.curr = this.curr;
                    if (typeof (onPageChangeCallback) === "function") onPageChangeCallback(this);
                }
            }

            layui.laypage($.extend({}, setting));
        }

        return module;
    });